//
// Created by 12992 on 24-10-16.
//

#include "color_space_to_string.h"
#include <unordered_map>

namespace utils
{
    using namespace std;
    static unordered_map<AVPixelFormat, string> color_space_map
            {
                    {AV_PIX_FMT_NONE,      "NONE"},
                    {AV_PIX_FMT_YUV420P,   "YUV420P"},
                    {AV_PIX_FMT_YUYV422,   "YUYV422"},
                    {AV_PIX_FMT_RGB24,     "RGB24"},
                    {AV_PIX_FMT_BGR24,     "BGR24"},
                    {AV_PIX_FMT_YUV422P,   "YUV422P"},
                    {AV_PIX_FMT_YUV444P,   "YUV444P"},
                    {AV_PIX_FMT_YUV410P,   "YUV410P"},
                    {AV_PIX_FMT_YUV411P,   "YUV411P"},
                    {AV_PIX_FMT_GRAY8,     "GRAY8"},
                    {AV_PIX_FMT_MONOWHITE, "MONOWHITE"},
                    {AV_PIX_FMT_MONOBLACK, "MONOBLACK"},
                    {AV_PIX_FMT_PAL8,      "PAL8"},
                    {AV_PIX_FMT_YUVJ420P,  "YUVJ420P"},
                    {AV_PIX_FMT_YUVJ422P,  "YUVJ422P"},
                    {AV_PIX_FMT_YUVJ444P,  "YUVJ444P"},
                    {AV_PIX_FMT_UYVY422,   "UYVY422"},
                    {AV_PIX_FMT_UYYVYY411, "UYYVYY411"},
                    {AV_PIX_FMT_BGR8,      "BGR8"},
                    {AV_PIX_FMT_BGR4,      "BGR4"},
                    {AV_PIX_FMT_BGR4_BYTE, "BGR4_BYTE"},
                    {AV_PIX_FMT_RGB8,      "RGB8"},
                    {AV_PIX_FMT_RGB4,      "RGB4"},
                    {AV_PIX_FMT_RGB4_BYTE, "RGB4_BYTE"},
                    {AV_PIX_FMT_NV12,      "NV12"},
                    {AV_PIX_FMT_NV21,      "NV21"},
                    {AV_PIX_FMT_ARGB,      "ARGB"},
                    {AV_PIX_FMT_RGBA,      "RGBA"},
                    {AV_PIX_FMT_ABGR,      "ABGR"},
                    {AV_PIX_FMT_BGRA,      "BGRA"},
                    {AV_PIX_FMT_GRAY16BE,  "GRAY16BE"},
                    {AV_PIX_FMT_GRAY16LE,  "GRAY16LE"},
                    {AV_PIX_FMT_YUV440P,   "YUV440P"},
                    {AV_PIX_FMT_YUVJ440P,  "YUVJ440P"},
                    {AV_PIX_FMT_YUVA420P,  "YUVA420P"},
                    {AV_PIX_FMT_RGB48BE,   "RGB48BE"},
                    {AV_PIX_FMT_RGB48LE,   "RGB48LE"},
                    {AV_PIX_FMT_RGB565BE,  "RGB565BE"},
                    {AV_PIX_FMT_RGB565LE,  "RGB565LE"},
                    {AV_PIX_FMT_RGB555BE,  "RGB555BE"},
                    {AV_PIX_FMT_RGB555LE,  "RGB555LE"},
                    {AV_PIX_FMT_BGR565BE,  "BGR565BE"},
                    {AV_PIX_FMT_BGR565LE,  "BGR565LE"},
                    {AV_PIX_FMT_BGR555BE,  "BGR555BE"},
                    {AV_PIX_FMT_BGR555LE,  "BGR555LE"}
            };

    std::string color_space_to_string(AVPixelFormat fmt)
    {
        auto it = color_space_map.find(fmt);
        if (it == color_space_map.end())
        {
            return "unknown";
        }
        else
        {
            return it->second;
        }
    }
}

